package com.ssy.lingxi.product.repository.es;

import com.ssy.lingxi.product.entity.es.EsCommodity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商品ES搜索引擎层
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/28
 */
@Repository
public interface EsCommodityRepository extends ElasticsearchRepository<EsCommodity,Long>{

    List<EsCommodity> findByMemberIdAndCommodityShopListShopId(Long memberId, Long shopId);

    List<EsCommodity> findByCustomerCategoryCategoryIdAndCommodityShopListShopId(Long categoryId, Long shopId);

    List<EsCommodity> findByMemberIdAndCustomerCategoryIdAndCommodityShopListShopId(Long memberId, Long categoryId, Long shopId);

    List<EsCommodity> findByStoreIdAndCustomerCategoryIdAndCommodityShopListShopId(Long storeId, Long categoryId, Long shopId);

    List<EsCommodity> findByStoreIdAndCommodityShopListShopId(Long storeId, Long shopId);

    EsCommodity findByUnitPricePicListId(Long unitPricePicId);

    List<EsCommodity> findByUnitPricePicListIdIn(List<Long> unitPricePicId);

    EsCommodity findByMemberListUnitPricePicListId(Long unitPricePicId);

    List<EsCommodity> findByMemberListUnitPricePicListIdIn(List<Long> unitPricePicId);

    List<EsCommodity>  findByIdIn(List<Long> idList);

    List<EsCommodity> findByStoreIdAndPriceType(Long storeId, Integer priceType, Pageable page);

    List<EsCommodity> findByStoreIdAndPriceTypeIsNot(Long storeId, Integer priceType, Pageable page);

    List<EsCommodity> findByMemberListChannelMemberIdAndPriceType(Long channelMemberId, Integer priceType, Pageable page);

    List<EsCommodity> findByMemberListChannelMemberIdAndPriceTypeIsNot(Long channelMemberId, Integer priceType, Pageable page);

    List<EsCommodity> findByMemberListChannelMemberIdAndMemberListChannelMemberRoleId(Long channelMemberId, Long channelMemberRoleId);

    List<EsCommodity> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);

    List<EsCommodity> findByMemberIdAndMemberRoleIdAndPriceType(Long memberId, Long memberRoleId, Integer priceType);

    List<EsCommodity> findByBrandId(Long brandId);

    List<EsCommodity> findByStoreIdInAndCommodityShopListShopId(List<Long> storeIdList, Long shopId);

    List<EsCommodity> findByBrandIdInAndCommodityShopListShopId(List<Long> brandIdList, Long shopId);

    List<EsCommodity> findByMemberListIdIn(List<Long> channelCommodityMemberIdList);

    List<EsCommodity> findByCustomerCategoryCategoryFullIdStartingWithAndCommodityShopListShopId(String customerCategoryId, Long shopId);

    List<EsCommodity> findByCommodityShopListShopId(Long shopId);

//    Commodity findFirstByMemberListChannelCommodityId(Long channelCommodityId);

    EsCommodity findFirstByMemberListChannelCommodityMemberId(Long channelCommodityMemberId);

    List<EsCommodity> findByMemberListChannelCommodityId(Long channelCommodityId);

    List<EsCommodity> findByCustomerCategoryFullIdStartingWithAndCommodityShopListShopId(String format, Long shopId);

    List<EsCommodity> findByCustomerCategoryFullIdStartingWithAndMemberListShopListShopId(String format, Long shopId);
}
